home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr18 / ter99.zip / PASCAL._XE / FON37_38.PAS next >
Pascal/Delphi Source File  |  1992-10-02  |  4KB  |  126 lines

  1. Program Convert34353637_to_38;
  2.  
  3. { A small Terminate utility to show how to upgrade the phonebook }
  4. {       Structures are Copyrighted by Bo Bendtsen 1992           }
  5.  
  6. {$I PHONE.34}
  7. {$I PHONE.38}
  8.  
  9. Var
  10.   PhoneFile,
  11.   NewPhoneFile : File;
  12.   P34          : PhoneRec34;
  13.   P38          : PhoneRec;
  14.   x            : Word;
  15.  
  16. Procedure FatalError(s:string);
  17. Begin
  18.   WriteLn('Fatal: '+s+#10#10);
  19.   Halt;
  20. End;
  21.  
  22. Begin
  23.   If Paramcount=0 Then
  24.   Begin
  25.     WriteLn('Terminate phonebook upgrade tool from 0.34,0.35,0.36,0.37 --=> 0.38');
  26.     WriteLn(#10'Syntax: FON37_38 phonebook.fon');
  27.     Halt;
  28.   End;
  29.  
  30.   FillChar(PHead34,Sizeof(PHead34),0);         { old header }
  31.   FillChar(PHead,Sizeof(PHead),0);             { new header }
  32.  
  33.   Assign(PhoneFile,Paramstr(1));
  34.   {$I-} Reset(PhoneFile,1); {$I+}
  35.   If IOResult=0 Then
  36.   Begin
  37.     { Read the header in the phone file }
  38.     {$I-} BlockRead(PhoneFile,PHead34,Sizeof(PHead34)); {$I+}
  39.     If IOResult<>0 Then FatalError('Error in start of phonebook');
  40.  
  41.     If (PHead34.Version='0.38ß') And (ParamStr(2)<>'/O') Then
  42.     Begin
  43.       WriteLn('This is allready a 0.38 phonebook  /O to overwrite warning');
  44.       Halt;
  45.     End;
  46.  
  47.     Assign(NewPhoneFile,'TERMINAT.TMP');
  48.     {$I-} Rewrite(NewPhoneFile,1); {$I+}
  49.     If IOResult=0 Then
  50.     Begin
  51.  
  52.       { Move old structure to new structure }
  53.  
  54.       PHead.Encrypted       :=        PHead34.Encrypted   ;
  55.       PHead.Seed            :=        PHead34.Seed        ;
  56.       PHead.Version         :=        PHead34.Version     ;
  57.       PHead.Comment         :=        PHead34.Comment     ;
  58.       PHead.Num             :=        PHead34.Num         ;
  59.       PHead.PhonePos        :=        PHead34.PhonePos    ;
  60.       PHead.ScrPos          :=        PHead34.ScrPos      ;
  61.       PHead.WritePos        :=        PHead34.WritePos    ;
  62.       PHead.RangeStart      :=        PHead34.RangeStart  ;
  63.       PHead.RangeStop       :=        PHead34.RangeStop   ;
  64.  
  65.       {$I-} BlockWrite(NewPhoneFile,PHead,Sizeof(PHead)); {$I+}
  66.       If IOResult<>0 Then FatalError('Could not write header');
  67.  
  68.       { Read all records into structure }
  69.       For x:=1 to PHead34.Num Do
  70.       Begin
  71.  
  72.         {$I-} BlockRead(PhoneFile,P34,Sizeof(P34)); {$I+}
  73.         Writeln(P34.Name);
  74.         If IOResult<>0 Then FatalError('Error in phonebook, maybe wrong version');
  75.  
  76.         FillChar(P38,sizeof(P38),0);
  77.  
  78.         P38.Name          :=   P34.Name         ;
  79.         P38.Number        :=   P34.Number       ;
  80.         P38.Baud          :=   P34.Baud         ;
  81.         P38.Parity        :=   P34.Parity       ;
  82.         P38.DataBits      :=   P34.DataBits     ;
  83.         P38.StopBits      :=   P34.StopBits     ;
  84.         P38.Script        :=   P34.Script       ;
  85.         P38.Terminal      :=   P34.Terminal     ;
  86.         P38.Protocol      :=   P34.Protocol     ;
  87.         P38.DialPrefix    :=   P34.DialPrefix   ;
  88.         P38.Password      :=   P34.Password     ;
  89.         P38.Open          :=   P34.Open         ;
  90.         P38.Closed        :=   P34.Closed       ;
  91.         P38.User          :=   P34.User         ;
  92.         P38.Comment1      :=   P34.Comment1     ;
  93.         P38.Comment2      :=   P34.Comment2     ;
  94.         P38.AutoLogon     :=   P34.AutoLogon    ;
  95.         P38.LogonChar     :=   P34.LogonChar    ;
  96.         P38.Translate     :=   P34.Translate    ;
  97.         P38.Capture       :=   P34.Capture      ;
  98.         P38.LocalEcho     :=   P34.LocalEcho    ;
  99.         P38.StripHigh     :=   P34.StripHigh    ;
  100.         P38.RcvdBSdest    :=   P34.RcvdBSdest   ;
  101.         P38.Color         :=   P34.Color        ;
  102.         P38.JulDate       :=   P34.JulDate      ;
  103.         P38.CalcMin       :=   P34.CalcMin      ;
  104.         P38.Connects      :=   P34.Connects     ;
  105.         P38.SecUsed       :=   P34.SecUsed      ;
  106.         P38.UploadKb      :=   P34.UploadKb     ;
  107.         P38.DownloadKb    :=   P34.DownloadKb   ;
  108.         P38.Costs         :=   P34.Costs        ;
  109.  
  110.         {$I-} BlockWrite(NewPhoneFile,P38,Sizeof(P38)); {$I+}
  111.         If IOResult<>0 Then FatalError('Could not write entry');
  112.  
  113.       End;
  114.  
  115.       Close(NewPhoneFile);
  116.       Close(PhoneFile);
  117.       Erase(PhoneFile);
  118.       Rename(NewPhoneFile,ParamStr(1));
  119.  
  120.     End;
  121.  
  122.  
  123.   End;
  124.  
  125. End.
  126.